#include "multiplytable.h"
#include "SimpleElementS.h"
#include "matrix.h"

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <stdexcept>

using namespace std;

void KeyGenerator(Matrix<SimpleElementS>& firstLinear, Matrix<SimpleElementS>& secondLinear,size_t littleDimen, size_t bigDimen)
{
	srand( (unsigned int)time(NULL));

	Word32 elementNum = 1 << littleDimen;

_first_start:
	for (size_t i = 0; i < bigDimen; i++)
	{
		for (size_t j = 0; j < bigDimen; j++)
		{
			firstLinear(i,j) = rand() % elementNum;
		}
	}
	try{
		firstLinear.invert();
	}catch(runtime_error&)
	{
		goto _first_start;
	}

_second_start:
	for (size_t i = 0; i < bigDimen; i++)
	{
		for (size_t j = 0; j < bigDimen; j++)
		{
			secondLinear(i,j) = rand() % elementNum;
		}
	}
	try{
		secondLinear.invert();
	}catch(runtime_error&)
	{
		goto _second_start;
	}

}

// int main()
// {
// 	Matrix<SimpleElementS> firstLinear(37,37),secondLinear(37,37);
// 	KeyGenerator(firstLinear,secondLinear,7, 37);
// 	cout<<firstLinear<<endl<<secondLinear;
// 	return 0;
// }
